package com.qdy.repository;

import com.qdy.entity.team.TeamMember;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

/**
 * Created by qudingyi on 2017/4/22.
 */
public interface TeamMemberRepository extends JpaRepository<TeamMember,Long> {

    @Modifying
    @Query("update TeamMember m set m.id= ?1 where m.status= ?2")
    int changeStatus(Long memBerId, Integer status);


    List<TeamMember> findByTeamIdAndStatusOrderByApplyTimeDesc(Long teamId,Integer status);

    @Modifying
    @Transactional
    @Query(value = "delete from t_team_member  where team_id=?1 and  user_id=?2",nativeQuery = true)
    void caenelApply(Long teamId,Long userId);


}
